// src/store/user.js
import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
  state: () => ({
    user: null,
    token: null
  }),
  getters: {
    isLoggedIn: (state) => !!state.user && !!state.token
  },
  actions: {
    setUser(data) {
      this.user = data?.user || { username: '调试用户' }
      this.token = data?.token || 'debug-token'
    },
    clearUser() {
      this.user = null
      this.token = null
    }
  }
})